package com.lcm.basic.p6.finall;

/**
 * @author Coder-lcm
 * @date 2021/3/31
 */
public class testFinall{
    public static void main(String[]args){
        Finall finall = new Finall();
        Finall finall2 = new Finall(2,"lcm02");
        System.out.println(finall);
        System.out.println(finall2);
        System.out.println(Finall.staticFinalInt);
        System.out.println(Finall.staticInt);
        finall.setStaticInt(123);
        System.out.println(Finall.staticInt);
    }
}

class Finall {
    // final修饰的变量只能初始化一次
    public static final int staticFinalInt;
    public static int staticInt;
    private final int id;
    private final String name;

    static {
        staticFinalInt =10;
        staticInt = 12;
    }

    public void setStaticInt(Integer a){
        staticInt = a;
    }

    public Finall() {
        this.id = 100;
        this.name = "lcm";
    }

    public Finall(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Finall{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}